package main

import (
	"fmt"
	"reflect"
)

func testReflect(a interface{})  {
	// get type
	rType := reflect.TypeOf(a)
	fmt.Printf("rType val is %v, type is %[1]T\n", rType)
	// rType val is int, type is *reflect.rtype

	// get Value
	rVal := reflect.ValueOf(a)
	fmt.Printf("rVal is %v, type is %[1]T\n", rVal)
	// rVal is 100, type is reflect.Value

	// get basic type val
	val := rVal.Int()
	fmt.Println(val) // 100

	// reflect.Value convert to interface
	a1 := rVal.Interface()
	fmt.Printf("a1 is %v, type is %[1]T\n", a1)
	// a1 is 100, type is int
}

func main() {
	var num int64 = 100
	testReflect(num)
}
